// -------------------------------------------------
// BlinKit - BkCrawler Library
// -------------------------------------------------
//   File Name: char_type.cpp
// Description: ICU Stub
//      Author: Ziming Li
//     Created: 2020-12-31
// -------------------------------------------------
// Copyright (C) 2020 MingYang Software Technology.
// -------------------------------------------------

#include "char_type.h"

namespace BlinKit {

struct CharRange {
    UChar from, to;
};

static bool CharInRanges(UChar32 c, const CharRange ranges[], size_t rangeCount)
{
    for (size_t i = 0; i < rangeCount; ++i)
    {
        const CharRange &range = ranges[i];
        if (range.from <= c && c <= range.to)
            return true;
    }
    return false;
}

static bool CharInArray(UChar32 c, const UChar charArray[], size_t arraySize)
{
    for (size_t i = 0; i < arraySize; ++i)
    {
        if (charArray[i] == c)
            return true;
    }
    return false;
}

bool IsDecimalDigit(UChar32 c)
{
    static const CharRange decimalDigitRanges[] = {
        { 0x0030, 0x0039 }, { 0x0660, 0x0669 }, { 0x06F0, 0x06F9 }, { 0x07C0, 0x07C9 }, { 0x0966, 0x096F },
        { 0x09E6, 0x09EF }, { 0x0A66, 0x0A6F }, { 0x0AE6, 0x0AEF }, { 0x0B66, 0x0B6F }, { 0x0BE6, 0x0BEF },
        { 0x0C66, 0x0C6F }, { 0x0CE6, 0x0CEF }, { 0x0D66, 0x0D6F }, { 0x0DE6, 0x0DEF }, { 0x0E50, 0x0E59 },
        { 0x0ED0, 0x0ED9 }, { 0x0F20, 0x0F29 }, { 0x1040, 0x1049 }, { 0x1090, 0x1099 }, { 0x17E0, 0x17E9 },
        { 0x1810, 0x1819 }, { 0x1946, 0x194F }, { 0x19D0, 0x19D9 }, { 0x1A80, 0x1A89 }, { 0x1A90, 0x1A99 },
        { 0x1B50, 0x1B59 }, { 0x1BB0, 0x1BB9 }, { 0x1C40, 0x1C49 }, { 0x1C50, 0x1C59 }, { 0xA620, 0xA629 },
        { 0xA8D0, 0xA8D9 }, { 0xA900, 0xA909 }, { 0xA9D0, 0xA9D9 }, { 0xA9F0, 0xA9F9 }, { 0xAA50, 0xAA59 },
        { 0xABF0, 0xABF9 }
    };
    return CharInRanges(c, decimalDigitRanges, std::size(decimalDigitRanges));
}

bool IsEnclosingMark(UChar32 c)
{
    if (0x0488 == c || 0x0489 == c || 0x1ABE == c)
        return true;

    static const CharRange enclosingMarkRanges[] = {
        { 0x20DD, 0x20E0 }, { 0x20E2, 0x20E4 }, { 0xA670, 0xA672 }
    };
    return CharInRanges(c, enclosingMarkRanges, std::size(enclosingMarkRanges));
}

bool IsModifierLetter(UChar32 c)
{
    static const UChar modifierLetters[] = {
        0x02EC, 0x02EE, 0x0374, 0x037A, 0x0559, 0x0640, 0x06E5, 0x06E6, 0x07F4, 0x07F5, 0x07FA, 0x081A, 0x0824, 0x0828,
        0x0971, 0x0E46, 0x0EC6, 0x10FC, 0x17D7, 0x1843, 0x1AA7, 0x1D78, 0x2071, 0x207F, 0x2C7C, 0x2C7D, 0x2D6F, 0x2E2F,
        0x3005, 0x303B, 0x309D, 0x309E, 0xA015, 0xA60C, 0xA67F, 0xA69C, 0xA69D, 0xA770, 0xA788, 0xA7F8, 0xA7F9, 0xA9CF,
        0xA9E6, 0xAA70, 0xAADD, 0xAAF3, 0xAAF4
    };

    if (CharInArray(c, modifierLetters, std::size(modifierLetters)))
        return true;

    static const CharRange modifierLetterRanges[] = {
        { 0x02B0, 0x02C1 }, { 0x02C6, 0x02D1 }, { 0x02E0, 0x02E4 }, { 0x1C78, 0x1C7D }, { 0x1D2C, 0x1D6A },
        { 0x1D9B, 0x1DBF }, { 0x2090, 0x209C }, { 0x3031, 0x3035 }, { 0x30FC, 0x30FE }, { 0xA4F8, 0xA4FD },
        { 0xA717, 0xA71F }, { 0xAB5C, 0xAB5F }
    };
    return CharInRanges(c, modifierLetterRanges, std::size(modifierLetterRanges));
}

bool IsNonSpacingMark(UChar32 c)
{
    static const UChar nonSpacingMarks[] = {
        0x05BF, 0x05C1, 0x05C2, 0x05C4, 0x05C5, 0x05C7, 0x0670, 0x06E7, 0x06E8, 0x0711, 0x093A, 0x093C, 0x094D, 0x0962,
        0x0963, 0x0981, 0x09BC, 0x09CD, 0x09E2, 0x09E3, 0x0A01, 0x0A02, 0x0A3C, 0x0A41, 0x0A42, 0x0A47, 0x0A48, 0x0A51,
        0x0A70, 0x0A71, 0x0A75, 0x0A81, 0x0A82, 0x0ABC, 0x0AC7, 0x0AC8, 0x0ACD, 0x0AE2, 0x0AE3, 0x0B01, 0x0B3C, 0x0B3F,
        0x0B4D, 0x0B56, 0x0B62, 0x0B63, 0x0B82, 0x0BC0, 0x0BCD, 0x0C00, 0x0C55, 0x0C56, 0x0C62, 0x0C63, 0x0C81, 0x0CBC,
        0x0CBF, 0x0CC6, 0x0CCC, 0x0CCD, 0x0CE2, 0x0CE3, 0x0D00, 0x0D01, 0x0D3B, 0x0D3C, 0x0D4D, 0x0D62, 0x0D63, 0x0DCA,
        0x0DD6, 0x0E31, 0x0EB1, 0x0EBB, 0x0EBC, 0x0F18, 0x0F19, 0x0F35, 0x0F37, 0x0F39, 0x0F86, 0x0F87, 0x0FC6, 0x1039,
        0x103A, 0x103D, 0x103E, 0x1058, 0x1059, 0x1082, 0x1085, 0x1086, 0x108D, 0x109D, 0x1752, 0x1753, 0x1772, 0x1773,
        0x17B4, 0x17B5, 0x17C6, 0x17DD, 0x1885, 0x1886, 0x18A9, 0x1927, 0x1928, 0x1932, 0x1A17, 0x1A18, 0x1A1B, 0x1A56,
        0x1A60, 0x1A62, 0x1A7F, 0x1B34, 0x1B3C, 0x1B42, 0x1B80, 0x1B81, 0x1BA8, 0x1BA9, 0x1BE6, 0x1BE8, 0x1BE9, 0x1BED,
        0x1C36, 0x1C37, 0x1CED, 0x1CF4, 0x1CF8, 0x1CF9, 0x20E1, 0x2D7F, 0x3099, 0x309A, 0xA66F, 0xA69E, 0xA69F, 0xA6F0,
        0xA6F1, 0xA802, 0xA806, 0xA80B, 0xA825, 0xA826, 0xA8C4, 0xA8C5, 0xA9B3, 0xA9BC, 0xA9E5, 0xAA31, 0xAA32, 0xAA35,
        0xAA36, 0xAA43, 0xAA4C, 0xAA7C, 0xAAB0, 0xAAB7, 0xAAB8, 0xAABE, 0xAABF, 0xAAC1, 0xAAEC, 0xAAED, 0xAAF6, 0xABE5,
        0xABE8, 0xABED
    };

    if (CharInArray(c, nonSpacingMarks, std::size(nonSpacingMarks)))
        return true;

    static const CharRange nonSpacingMarkRanges[] = {
        { 0x0300, 0x036F }, { 0x0483, 0x0487 }, { 0x0591, 0x05BD }, { 0x0610, 0x061A }, { 0x064B, 0x065F },
        { 0x06D6, 0x06DC }, { 0x06DF, 0x06E4 }, { 0x06EA, 0x06ED }, { 0x0730, 0x074A }, { 0x07A6, 0x07B0 },
        { 0x07EB, 0x07F3 }, { 0x0816, 0x0819 }, { 0x081B, 0x0823 }, { 0x0825, 0x0827 }, { 0x0829, 0x082D },
        { 0x0859, 0x085B }, { 0x08D4, 0x08E1 }, { 0x08E3, 0x0902 }, { 0x0941, 0x0948 }, { 0x0951, 0x0957 },
        { 0x09C1, 0x09C4 }, { 0x0A4B, 0x0A4D }, { 0x0AC1, 0x0AC5 }, { 0x0AFA, 0x0AFF }, { 0x0B41, 0x0B44 },
        { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0D41, 0x0D44 }, { 0x0DD2, 0x0DD4 },
        { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB4, 0x0EB9 }, { 0x0EC8, 0x0ECD }, { 0x0F71, 0x0F7E },
        { 0x0F80, 0x0F84 }, { 0x0F8D, 0x0F97 }, { 0x0F99, 0x0FBC }, { 0x102D, 0x1030 }, { 0x1032, 0x1037 },
        { 0x105E, 0x1060 }, { 0x1071, 0x1074 }, { 0x135D, 0x135F }, { 0x1712, 0x1714 }, { 0x1732, 0x1734 },
        { 0x17B7, 0x17BD }, { 0x17C9, 0x17D3 }, { 0x180B, 0x180D }, { 0x1920, 0x1922 }, { 0x1939, 0x193B },
        { 0x1A58, 0x1A5E }, { 0x1A65, 0x1A6C }, { 0x1A73, 0x1A7C }, { 0x1AB0, 0x1ABD }, { 0x1B00, 0x1B03 },
        { 0x1B36, 0x1B3A }, { 0x1B6B, 0x1B73 }, { 0x1BA2, 0x1BA5 }, { 0x1BAB, 0x1BAD }, { 0x1BEF, 0x1BF1 },
        { 0x1C2C, 0x1C33 }, { 0x1CD0, 0x1CD2 }, { 0x1CD4, 0x1CE0 }, { 0x1CE2, 0x1CE8 }, { 0x1DC0, 0x1DF9 },
        { 0x1DFB, 0x1DFF }, { 0x20D0, 0x20DC }, { 0x20E5, 0x20F0 }, { 0x2CEF, 0x2CF1 }, { 0x2DE0, 0x2DFF },
        { 0x302A, 0x302D }, { 0xA674, 0xA67D }, { 0xA8E0, 0xA8F1 }, { 0xA926, 0xA92D }, { 0xA947, 0xA951 },
        { 0xA980, 0xA982 }, { 0xA9B6, 0xA9B9 }, { 0xAA29, 0xAA2E }, { 0xAAB2, 0xAAB4 }
    };
    return CharInRanges(c, nonSpacingMarkRanges, std::size(nonSpacingMarkRanges));
}

bool IsNumberLetter(UChar32 c)
{
    if (0x3007 == c)
        return true;

    static const CharRange numberLetterRanges[] = {
        { 0x16EE, 0x16F0 }, { 0x2160, 0x2182 }, { 0x2185, 0x2188 }, { 0x3021, 0x3029 }, { 0x3038, 0x303A },
        { 0xA6E6, 0xA6EF }
    };
    return CharInRanges(c, numberLetterRanges, std::size(numberLetterRanges));
}

bool IsOtherLetter(UChar32 c)
{
    static const UChar otherLetters[] = {
        0x00AA, 0x00BA, 0x01BB, 0x0294, 0x066E, 0x066F, 0x06D5, 0x06EE, 0x06EF, 0x06FF, 0x0710, 0x07B1, 0x093D, 0x0950,
        0x098F, 0x0990, 0x09B2, 0x09BD, 0x09CE, 0x09DC, 0x09DD, 0x09F0, 0x09F1, 0x09FC, 0x0A0F, 0x0A10, 0x0A32, 0x0A33,
        0x0A35, 0x0A36, 0x0A38, 0x0A39, 0x0A5E, 0x0AB2, 0x0AB3, 0x0ABD, 0x0AD0, 0x0AE0, 0x0AE1, 0x0AF9, 0x0B0F, 0x0B10,
        0x0B32, 0x0B33, 0x0B3D, 0x0B5C, 0x0B5D, 0x0B71, 0x0B83, 0x0B99, 0x0B9A, 0x0B9C, 0x0B9E, 0x0B9F, 0x0BA3, 0x0BA4,
        0x0BD0, 0x0C3D, 0x0C60, 0x0C61, 0x0C80, 0x0CBD, 0x0CDE, 0x0CE0, 0x0CE1, 0x0CF1, 0x0CF2, 0x0D3D, 0x0D4E, 0x0DBD,
        0x0E32, 0x0E33, 0x0E81, 0x0E82, 0x0E84, 0x0E87, 0x0E88, 0x0E8A, 0x0E8D, 0x0EA5, 0x0EA7, 0x0EAA, 0x0EAB, 0x0EB2,
        0x0EB3, 0x0EBD, 0x0F00, 0x103F, 0x1061, 0x1065, 0x1066, 0x108E, 0x1258, 0x12C0, 0x17DC, 0x18AA, 0x1BAE, 0x1BAF,
        0x1CF5, 0x1CF6, 0x3006, 0x303C, 0x309F, 0x30FF, 0xA62A, 0xA62B, 0xA66E, 0xA78F, 0xA7F7, 0xA8FB, 0xA8FD, 0xAA7A,
        0xAAB1, 0xAAB5, 0xAAB6, 0xAAC0, 0xAAC2, 0xAADB, 0xAADC, 0xAAF2
    };

    if (CharInArray(c, otherLetters, std::size(otherLetters)))
        return true;

    static const CharRange otherLetterRanges[] = {
        { 0x01C0, 0x01C3 }, { 0x05D0, 0x05EA }, { 0x05F0, 0x05F2 }, { 0x0620, 0x063F }, { 0x0641, 0x064A },
        { 0x0671, 0x06D3 }, { 0x06FA, 0x06FC }, { 0x0712, 0x072F }, { 0x074D, 0x07A5 }, { 0x07CA, 0x07EA },
        { 0x0800, 0x0815 }, { 0x0840, 0x0858 }, { 0x0860, 0x086A }, { 0x08A0, 0x08B4 }, { 0x08B6, 0x08BD },
        { 0x0904, 0x0939 }, { 0x0958, 0x0961 }, { 0x0972, 0x0980 }, { 0x0985, 0x098C }, { 0x0993, 0x09A8 },
        { 0x09AA, 0x09B0 }, { 0x09B6, 0x09B9 }, { 0x09DF, 0x09E1 }, { 0x0A05, 0x0A0A }, { 0x0A13, 0x0A28 },
        { 0x0A2A, 0x0A30 }, { 0x0A59, 0x0A5C }, { 0x0A72, 0x0A74 }, { 0x0A85, 0x0A8D }, { 0x0A8F, 0x0A91 },
        { 0x0A93, 0x0AA8 }, { 0x0AAA, 0x0AB0 }, { 0x0AB5, 0x0AB9 }, { 0x0B05, 0x0B0C }, { 0x0B13, 0x0B28 },
        { 0x0B2A, 0x0B30 }, { 0x0B35, 0x0B39 }, { 0x0B5F, 0x0B61 }, { 0x0B85, 0x0B8A }, { 0x0B8E, 0x0B90 },
        { 0x0B92, 0x0B95 }, { 0x0BA8, 0x0BAA }, { 0x0BAE, 0x0BB9 }, { 0x0C05, 0x0C0C }, { 0x0C0E, 0x0C10 },
        { 0x0C12, 0x0C28 }, { 0x0C2A, 0x0C39 }, { 0x0C58, 0x0C5A }, { 0x0C85, 0x0C8C }, { 0x0C8E, 0x0C90 },
        { 0x0C92, 0x0CA8 }, { 0x0CAA, 0x0CB3 }, { 0x0CB5, 0x0CB9 }, { 0x0D05, 0x0D0C }, { 0x0D0E, 0x0D10 },
        { 0x0D12, 0x0D3A }, { 0x0D54, 0x0D56 }, { 0x0D5F, 0x0D61 }, { 0x0D7A, 0x0D7F }, { 0x0D85, 0x0D96 },
        { 0x0D9A, 0x0DB1 }, { 0x0DB3, 0x0DBB }, { 0x0DC0, 0x0DC6 }, { 0x0E01, 0x0E30 }, { 0x0E40, 0x0E45 },
        { 0x0E94, 0x0E97 }, { 0x0E99, 0x0E9F }, { 0x0EA1, 0x0EA3 }, { 0x0EAD, 0x0EB0 }, { 0x0EC0, 0x0EC4 },
        { 0x0EDC, 0x0EDF }, { 0x0F40, 0x0F47 }, { 0x0F49, 0x0F6C }, { 0x0F88, 0x0F8C }, { 0x1000, 0x102A },
        { 0x1050, 0x1055 }, { 0x105A, 0x105D }, { 0x106E, 0x1070 }, { 0x1075, 0x1081 }, { 0x10D0, 0x10FA },
        { 0x10FD, 0x1248 }, { 0x124A, 0x124D }, { 0x1250, 0x1256 }, { 0x125A, 0x125D }, { 0x1260, 0x1288 },
        { 0x128A, 0x128D }, { 0x1290, 0x12B0 }, { 0x12B2, 0x12B5 }, { 0x12B8, 0x12BE }, { 0x12C2, 0x12C5 },
        { 0x12C8, 0x12D6 }, { 0x12D8, 0x1310 }, { 0x1312, 0x1315 }, { 0x1318, 0x135A }, { 0x1380, 0x138F },
        { 0x1401, 0x166C }, { 0x166F, 0x167F }, { 0x1681, 0x169A }, { 0x16A0, 0x16EA }, { 0x16F1, 0x16F8 },
        { 0x1700, 0x170C }, { 0x170E, 0x1711 }, { 0x1720, 0x1731 }, { 0x1740, 0x1751 }, { 0x1760, 0x176C },
        { 0x176E, 0x1770 }, { 0x1780, 0x17B3 }, { 0x1820, 0x1842 }, { 0x1844, 0x1877 }, { 0x1880, 0x1884 },
        { 0x1887, 0x18A8 }, { 0x18B0, 0x18F5 }, { 0x1900, 0x191E }, { 0x1950, 0x196D }, { 0x1970, 0x1974 },
        { 0x1980, 0x19AB }, { 0x19B0, 0x19C9 }, { 0x1A00, 0x1A16 }, { 0x1A20, 0x1A54 }, { 0x1B05, 0x1B33 },
        { 0x1B45, 0x1B4B }, { 0x1B83, 0x1BA0 }, { 0x1BBA, 0x1BE5 }, { 0x1C00, 0x1C23 }, { 0x1C4D, 0x1C4F },
        { 0x1C5A, 0x1C77 }, { 0x1CE9, 0x1CEC }, { 0x1CEE, 0x1CF1 }, { 0x2135, 0x2138 }, { 0x2D30, 0x2D67 },
        { 0x2D80, 0x2D96 }, { 0x2DA0, 0x2DA6 }, { 0x2DA8, 0x2DAE }, { 0x2DB0, 0x2DB6 }, { 0x2DB8, 0x2DBE },
        { 0x2DC0, 0x2DC6 }, { 0x2DC8, 0x2DCE }, { 0x2DD0, 0x2DD6 }, { 0x2DD8, 0x2DDE }, { 0x3041, 0x3096 },
        { 0x30A1, 0x30FA }, { 0x3105, 0x312E }, { 0x3131, 0x318E }, { 0x31A0, 0x31BA }, { 0x31F0, 0x31FF },
        { 0x3400, 0x4DB5 }, { 0x4E00, 0x9FEA }, { 0xA000, 0xA014 }, { 0xA016, 0xA48C }, { 0xA4D0, 0xA4F7 },
        { 0xA500, 0xA60B }, { 0xA610, 0xA61F }, { 0xA6A0, 0xA6E5 }, { 0xA7FB, 0xA801 }, { 0xA803, 0xA805 },
        { 0xA807, 0xA80A }, { 0xA80C, 0xA822 }, { 0xA840, 0xA873 }, { 0xA882, 0xA8B3 }, { 0xA8F2, 0xA8F7 },
        { 0xA90A, 0xA925 }, { 0xA930, 0xA946 }, { 0xA960, 0xA97C }, { 0xA984, 0xA9B2 }, { 0xA9E0, 0xA9E4 },
        { 0xA9E7, 0xA9EF }, { 0xA9FA, 0xA9FE }, { 0xAA00, 0xAA28 }, { 0xAA40, 0xAA42 }, { 0xAA44, 0xAA4B },
        { 0xAA60, 0xAA6F }, { 0xAA71, 0xAA76 }, { 0xAA7E, 0xAAAF }, { 0xAAB9, 0xAABD }, { 0xAAE0, 0xAAEA },
        { 0xAB01, 0xAB06 }, { 0xAB09, 0xAB0E }, { 0xAB11, 0xAB16 }, { 0xAB20, 0xAB26 }, { 0xAB28, 0xAB2E },
        { 0xABC0, 0xABE2 }, { 0xAC00, 0xD7A3 }, { 0xD7B0, 0xD7C6 }, { 0xD7CB, 0xD7FB }
    };
    return CharInRanges(c, otherLetterRanges, std::size(otherLetterRanges));
}

bool IsSpacingCombiningMark(UChar32 c)
{
    static const UChar spacingCombiningMarks[] = {
        0x0903, 0x093B, 0x094E, 0x094F, 0x0982, 0x0983, 0x09C7, 0x09C8, 0x09CB, 0x09CC, 0x09D7, 0x0A03, 0x0A83, 0x0AC9,
        0x0ACB, 0x0ACC, 0x0B02, 0x0B03, 0x0B3E, 0x0B40, 0x0B47, 0x0B48, 0x0B4B, 0x0B4C, 0x0B57, 0x0BBE, 0x0BBF, 0x0BC1,
        0x0BC2, 0x0BD7, 0x0C82, 0x0C83, 0x0CBE, 0x0CC7, 0x0CC8, 0x0CCA, 0x0CCB, 0x0CD5, 0x0CD6, 0x0D02, 0x0D03, 0x0D57,
        0x0D82, 0x0D83, 0x0DF2, 0x0DF3, 0x0F3E, 0x0F3F, 0x0F7F, 0x102B, 0x102C, 0x1031, 0x1038, 0x103B, 0x103C, 0x1056,
        0x1057, 0x1083, 0x1084, 0x108F, 0x17B6, 0x17C7, 0x17C8, 0x1930, 0x1931, 0x1A19, 0x1A1A, 0x1A55, 0x1A57, 0x1A61,
        0x1A63, 0x1A64, 0x1B04, 0x1B35, 0x1B3B, 0x1B43, 0x1B44, 0x1B82, 0x1BA1, 0x1BA6, 0x1BA7, 0x1BAA, 0x1BE7, 0x1BEE,
        0x1BF2, 0x1BF3, 0x1C34, 0x1C35, 0x1CE1, 0x1CF2, 0x1CF3, 0x1CF7, 0x302E, 0x302F, 0xA823, 0xA824, 0xA827, 0xA880,
        0xA881, 0xA952, 0xA953, 0xA983, 0xA9B4, 0xA9B5, 0xA9BA, 0xA9BB, 0xAA2F, 0xAA30, 0xAA33, 0xAA34, 0xAA4D, 0xAA7B,
        0xAA7D, 0xAAEB, 0xAAEE, 0xAAEF, 0xAAF5, 0xABE3, 0xABE4, 0xABE6, 0xABE7, 0xABE9, 0xABEA, 0xABEC
    };

    if (CharInArray(c, spacingCombiningMarks, std::size(spacingCombiningMarks)))
        return true;

    static const CharRange spacingCombiningMarkRanges[] = {
        { 0x093E, 0x0940 }, { 0x0949, 0x094C }, { 0x09BE, 0x09C0 }, { 0x0A3E, 0x0A40 }, { 0x0ABE, 0x0AC0 },
        { 0x0BC6, 0x0BC8 }, { 0x0BCA, 0x0BCC }, { 0x0C01, 0x0C03 }, { 0x0C41, 0x0C44 }, { 0x0CC0, 0x0CC4 },
        { 0x0D3E, 0x0D40 }, { 0x0D46, 0x0D48 }, { 0x0D4A, 0x0D4C }, { 0x0DCF, 0x0DD1 }, { 0x0DD8, 0x0DDF },
        { 0x1062, 0x1064 }, { 0x1067, 0x106D }, { 0x1087, 0x108C }, { 0x109A, 0x109C }, { 0x17BE, 0x17C5 },
        { 0x1923, 0x1926 }, { 0x1929, 0x192B }, { 0x1933, 0x1938 }, { 0x1A6D, 0x1A72 }, { 0x1B3D, 0x1B41 },
        { 0x1BEA, 0x1BEC }, { 0x1C24, 0x1C2B }, { 0xA8B4, 0xA8C3 }, { 0xA9BD, 0xA9C0 }
    };
    return CharInRanges(c, spacingCombiningMarkRanges, std::size(spacingCombiningMarkRanges));
}

bool IsTitlecaseLetter(UChar32 c)
{
    static const UChar titlecaseLetters[] = {
        0x01C5, 0x01C8, 0x01CB, 0x01F2, 0x1FBC, 0x1FCC, 0x1FFC
    };

    if (CharInArray(c, titlecaseLetters, std::size(titlecaseLetters)))
        return true;

    static const CharRange titlecaseLetterRanges[] = {
        { 0x1F88, 0x1F8F }, { 0x1F98, 0x1F9F }, { 0x1FA8, 0x1FAF }
    };
    return CharInRanges(c, titlecaseLetterRanges, std::size(titlecaseLetterRanges));
}

} // namespace BlinKit
